package ui;

import java.awt.Cursor;
import java.awt.Graphics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;



public class Userschoice extends JFrame{
	//面板组件
	private static final long serialVersionUID = 1L;
    private JButton teacherButton;
    private JButton studentButton;
    private JPanel panel;
  
    
    public static void main(String[] args) {
    	try {
            // 启动登陆界面
    		
    		Userschoice f = new Userschoice();
            f.setVisible(true);
   		 
   	    
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    
    
    public Userschoice() {
       
    	
    	setTitle("用户选择");
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        setBounds(700, 300, 500, 400);
        //setSize(500, 400);

        panel = new JPanel() {
            private static final long serialVersionUID = 1L;
            @Override//铺设背景图片
            protected void paintComponent(Graphics g) {
                super.paintComponent(g);
                g.drawImage(new ImageIcon(
                        "images/图片4.png").getImage(), 0,
                        0, getWidth(), getHeight(), null);
            }
        };
        panel.setBorder(new EmptyBorder(5, 5, 5, 5));
        setContentPane(panel);
        panel.setLayout(null);
        
        //教师按钮
        teacherButton = new JButton("教师登录");
        teacherButton.setIcon(new ImageIcon("images\\图片8.png"));//设置图标背景
        teacherButton.setBounds(110, 260, 100, 50);
        teacherButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));//设置鼠标在该区域显示状态变化
        //getRootPane().setDefaultButton(btnNewButton);//设置回车响应
        panel.add(teacherButton);
        
        //学生按钮
        studentButton = new JButton("学生登录");
        studentButton.setIcon(new ImageIcon("images\\图片8.png"));//设置图标背景
        studentButton.setBounds(290, 260, 100, 50);
        studentButton.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));//设置鼠标在该区域显示状态变化
        panel.add(studentButton);
        
     // 监听教师登陆按钮
        teacherButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {	
            try {
            	LoginFrame frame = new LoginFrame("Teacher");
                frame.setVisible(true);
                setVisible(false);// 隐藏掉登陆界面
                
            } catch (Exception e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }
                
                
            }
        });
        // 监听学生登陆按钮 
        studentButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
            	
            
            try {
            	
            	LoginFrame frame = new LoginFrame("Student");
                frame.setVisible(true);
                setVisible(false);// 隐藏掉登陆界面
                
            } catch (Exception e1) {
                // TODO Auto-generated catch block
                e1.printStackTrace();
            }    
            }
        });


       
 }
}
